
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>类 · TypeScript Handbook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Patrick Zhong">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Functions.html" />
    
    
    <link rel="prev" href="Interfaces.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="tutorials/">
            
                <a href="tutorials/">
            
                    
                    快速上手
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="tutorials/TypeScript in 5 minutes.html">
            
                <a href="tutorials/TypeScript in 5 minutes.html">
            
                    
                    5分钟了解TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="tutorials/ASP.NET Core.html">
            
                <a href="tutorials/ASP.NET Core.html">
            
                    
                    ASP.NET Core
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="tutorials/ASP.NET 4.html">
            
                <a href="tutorials/ASP.NET 4.html">
            
                    
                    ASP.NET 4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="tutorials/Gulp.html">
            
                <a href="tutorials/Gulp.html">
            
                    
                    Gulp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="tutorials/Knockout.html">
            
                <a href="tutorials/Knockout.html">
            
                    
                    Knockout.js
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="tutorials/React & Webpack.html">
            
                <a href="tutorials/React & Webpack.html">
            
                    
                    React与webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="tutorials/React.html">
            
                <a href="tutorials/React.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="tutorials/Angular 2.html">
            
                <a href="tutorials/Angular 2.html">
            
                    
                    Angular 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="tutorials/Migrating from JavaScript.html">
            
                <a href="tutorials/Migrating from JavaScript.html">
            
                    
                    从JavaScript迁移到TypeScript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    手册
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="Basic Types.html">
            
                <a href="Basic Types.html">
            
                    
                    基础类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="Variable Declarations.html">
            
                <a href="Variable Declarations.html">
            
                    
                    变量声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="Interfaces.html">
            
                <a href="Interfaces.html">
            
                    
                    接口
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.4" data-path="Classes.html">
            
                <a href="Classes.html">
            
                    
                    类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="Functions.html">
            
                <a href="Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="Generics.html">
            
                <a href="Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="Enums.html">
            
                <a href="Enums.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="Type Inference.html">
            
                <a href="Type Inference.html">
            
                    
                    类型推论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="Type Compatibility.html">
            
                <a href="Type Compatibility.html">
            
                    
                    类型兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="Advanced Types.html">
            
                <a href="Advanced Types.html">
            
                    
                    高级类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="Utilit Types.md">
            
                <span>
            
                    
                    实用工具类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.12" data-path="Symbols.html">
            
                <a href="Symbols.html">
            
                    
                    Symbols
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="Iterators and Generators.html">
            
                <a href="Iterators and Generators.html">
            
                    
                    Iterators 和 Generators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="Modules.html">
            
                <a href="Modules.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="Namespaces.html">
            
                <a href="Namespaces.html">
            
                    
                    命名空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="Namespaces and Modules.html">
            
                <a href="Namespaces and Modules.html">
            
                    
                    命名空间和模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="Module Resolution.html">
            
                <a href="Module Resolution.html">
            
                    
                    模块解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="Declaration Merging.html">
            
                <a href="Declaration Merging.html">
            
                    
                    声明合并
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="Writing Definition Files.html">
            
                <a href="Writing Definition Files.html">
            
                    
                    书写.d.ts文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="JSX.html">
            
                <a href="JSX.html">
            
                    
                    JSX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="Decorators.html">
            
                <a href="Decorators.html">
            
                    
                    Decorators
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="Mixins.html">
            
                <a href="Mixins.html">
            
                    
                    混入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="Triple-Slash Directives.html">
            
                <a href="Triple-Slash Directives.html">
            
                    
                    三斜线指令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="Type Checking JavaScript Files.html">
            
                <a href="Type Checking JavaScript Files.html">
            
                    
                    JavaScript文件里的类型检查
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="declaration files/Introduction.html">
            
                <a href="declaration files/Introduction.html">
            
                    
                    如何书写声明文件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="declaration files/Library Structures.html">
            
                <a href="declaration files/Library Structures.html">
            
                    
                    结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="declaration files/Do's and Don'ts.html">
            
                <a href="declaration files/Do's and Don'ts.html">
            
                    
                    规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="declaration files/By Example.html">
            
                <a href="declaration files/By Example.html">
            
                    
                    举例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="declaration files/Deep Dive.html">
            
                <a href="declaration files/Deep Dive.html">
            
                    
                    深入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="declaration files/Publishing.html">
            
                <a href="declaration files/Publishing.html">
            
                    
                    发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="declaration files/Consumption.html">
            
                <a href="declaration files/Consumption.html">
            
                    
                    使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="tsconfig.json.html">
            
                <a href="tsconfig.json.html">
            
                    
                    工程配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="tsconfig.json.html">
            
                <a href="tsconfig.json.html">
            
                    
                    tsconfig.json
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="Project References.html">
            
                <a href="Project References.html">
            
                    
                    工程引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="Typings for NPM Packages.html">
            
                <a href="Typings for NPM Packages.html">
            
                    
                    NPM包的类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="Compiler Options.html">
            
                <a href="Compiler Options.html">
            
                    
                    编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="Configuring Watch.html">
            
                <a href="Configuring Watch.html">
            
                    
                    配置 Watch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="Compiler Options in MSBuild.html">
            
                <a href="Compiler Options in MSBuild.html">
            
                    
                    在MSBuild里使用编译选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.7" data-path="Integrating with Build Tools.html">
            
                <a href="Integrating with Build Tools.html">
            
                    
                    与其它构建工具整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.8" data-path="Nightly Builds.html">
            
                <a href="Nightly Builds.html">
            
                    
                    使用TypeScript的每日构建版本
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../wiki/">
            
                <a href="../wiki/">
            
                    
                    Wiki
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../wiki/this-in-TypeScript.html">
            
                <a href="../wiki/this-in-TypeScript.html">
            
                    
                    TypeScript里的this
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../wiki/coding_guidelines.html">
            
                <a href="../wiki/coding_guidelines.html">
            
                    
                    编码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../wiki/Common Errors.html">
            
                <a href="../wiki/Common Errors.html">
            
                    
                    常见编译错误
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../wiki/TypeScript-Editor-Support.html">
            
                <a href="../wiki/TypeScript-Editor-Support.html">
            
                    
                    支持TypeScript的编辑器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                <a href="../wiki/Using-TypeScript-With-ASP.NET-5.html">
            
                    
                    结合ASP.NET v5使用TypeScript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../wiki/Architectural-Overview.html">
            
                <a href="../wiki/Architectural-Overview.html">
            
                    
                    架构概述
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../wiki/Roadmap.html">
            
                <a href="../wiki/Roadmap.html">
            
                    
                    发展路线图
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../release-notes/">
            
                <a href="../release-notes/">
            
                    
                    新增功能
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../release-notes/TypeScript 3.1.html">
            
                <a href="../release-notes/TypeScript 3.1.html">
            
                    
                    TypeScript 3.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../release-notes/TypeScript 3.0.html">
            
                <a href="../release-notes/TypeScript 3.0.html">
            
                    
                    TypeScript 3.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../release-notes/TypeScript 2.9.html">
            
                <a href="../release-notes/TypeScript 2.9.html">
            
                    
                    TypeScript 2.9
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../release-notes/TypeScript 2.8.html">
            
                <a href="../release-notes/TypeScript 2.8.html">
            
                    
                    TypeScript 2.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../release-notes/TypeScript 2.7.html">
            
                <a href="../release-notes/TypeScript 2.7.html">
            
                    
                    TypeScript 2.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../release-notes/TypeScript 2.6.html">
            
                <a href="../release-notes/TypeScript 2.6.html">
            
                    
                    TypeScript 2.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../release-notes/TypeScript 2.5.html">
            
                <a href="../release-notes/TypeScript 2.5.html">
            
                    
                    TypeScript 2.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../release-notes/TypeScript 2.4.html">
            
                <a href="../release-notes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="../release-notes/TypeScript 2.3.html">
            
                <a href="../release-notes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="../release-notes/TypeScript 2.2.html">
            
                <a href="../release-notes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.11" data-path="../release-notes/TypeScript 2.1.html">
            
                <a href="../release-notes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.12" data-path="../release-notes/TypeScript 2.0.html">
            
                <a href="../release-notes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.13" data-path="../release-notes/TypeScript 1.8.html">
            
                <a href="../release-notes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.14" data-path="../release-notes/TypeScript 1.7.html">
            
                <a href="../release-notes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.15" data-path="../release-notes/TypeScript 1.6.html">
            
                <a href="../release-notes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.16" data-path="../release-notes/TypeScript 1.5.html">
            
                <a href="../release-notes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.17" data-path="../release-notes/TypeScript 1.4.html">
            
                <a href="../release-notes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.18" data-path="../release-notes/TypeScript 1.3.html">
            
                <a href="../release-notes/TypeScript 1.3.html">
            
                    
                    TypeScript 1.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.19" data-path="../release-notes/TypeScript 1.1.html">
            
                <a href="../release-notes/TypeScript 1.1.html">
            
                    
                    TypeScript 1.1
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../breaking-changes/breaking-changes.html">
            
                <a href="../breaking-changes/breaking-changes.html">
            
                    
                    Breaking Changes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../breaking-changes/TypeScript 2.4.html">
            
                <a href="../breaking-changes/TypeScript 2.4.html">
            
                    
                    TypeScript 2.4
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../breaking-changes/TypeScript 2.3.html">
            
                <a href="../breaking-changes/TypeScript 2.3.html">
            
                    
                    TypeScript 2.3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../breaking-changes/TypeScript 2.2.html">
            
                <a href="../breaking-changes/TypeScript 2.2.html">
            
                    
                    TypeScript 2.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../breaking-changes/TypeScript 2.1.html">
            
                <a href="../breaking-changes/TypeScript 2.1.html">
            
                    
                    TypeScript 2.1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../breaking-changes/TypeScript 2.0.html">
            
                <a href="../breaking-changes/TypeScript 2.0.html">
            
                    
                    TypeScript 2.0
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../breaking-changes/TypeScript 1.8.html">
            
                <a href="../breaking-changes/TypeScript 1.8.html">
            
                    
                    TypeScript 1.8
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../breaking-changes/TypeScript 1.7.html">
            
                <a href="../breaking-changes/TypeScript 1.7.html">
            
                    
                    TypeScript 1.7
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../breaking-changes/TypeScript 1.6.html">
            
                <a href="../breaking-changes/TypeScript 1.6.html">
            
                    
                    TypeScript 1.6
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../breaking-changes/TypeScript 1.5.html">
            
                <a href="../breaking-changes/TypeScript 1.5.html">
            
                    
                    TypeScript 1.5
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../breaking-changes/TypeScript 1.4.html">
            
                <a href="../breaking-changes/TypeScript 1.4.html">
            
                    
                    TypeScript 1.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >类</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4ECB;&#x7ECD;">&#x4ECB;&#x7ECD;</h1>
<p>&#x4F20;&#x7EDF;&#x7684;JavaScript&#x7A0B;&#x5E8F;&#x4F7F;&#x7528;&#x51FD;&#x6570;&#x548C;&#x57FA;&#x4E8E;&#x539F;&#x578B;&#x7684;&#x7EE7;&#x627F;&#x6765;&#x521B;&#x5EFA;&#x53EF;&#x91CD;&#x7528;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x4F46;&#x5BF9;&#x4E8E;&#x719F;&#x6089;&#x4F7F;&#x7528;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x65B9;&#x5F0F;&#x7684;&#x7A0B;&#x5E8F;&#x5458;&#x6765;&#x8BB2;&#x5C31;&#x6709;&#x4E9B;&#x68D8;&#x624B;&#xFF0C;&#x56E0;&#x4E3A;&#x4ED6;&#x4EEC;&#x7528;&#x7684;&#x662F;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x7EE7;&#x627F;&#x5E76;&#x4E14;&#x5BF9;&#x8C61;&#x662F;&#x7531;&#x7C7B;&#x6784;&#x5EFA;&#x51FA;&#x6765;&#x7684;&#x3002;
&#x4ECE;ECMAScript 2015&#xFF0C;&#x4E5F;&#x5C31;&#x662F;ECMAScript 6&#x5F00;&#x59CB;&#xFF0C;JavaScript&#x7A0B;&#x5E8F;&#x5458;&#x5C06;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#x65B9;&#x5F0F;&#x3002;
&#x4F7F;&#x7528;TypeScript&#xFF0C;&#x6211;&#x4EEC;&#x5141;&#x8BB8;&#x5F00;&#x53D1;&#x8005;&#x73B0;&#x5728;&#x5C31;&#x4F7F;&#x7528;&#x8FD9;&#x4E9B;&#x7279;&#x6027;&#xFF0C;&#x5E76;&#x4E14;&#x7F16;&#x8BD1;&#x540E;&#x7684;JavaScript&#x53EF;&#x4EE5;&#x5728;&#x6240;&#x6709;&#x4E3B;&#x6D41;&#x6D4F;&#x89C8;&#x5668;&#x548C;&#x5E73;&#x53F0;&#x4E0A;&#x8FD0;&#x884C;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;&#x7B49;&#x5230;&#x4E0B;&#x4E2A;JavaScript&#x7248;&#x672C;&#x3002;</p>
<h1 id="&#x7C7B;">&#x7C7B;</h1>
<p>&#x4E0B;&#x9762;&#x770B;&#x4E00;&#x4E2A;&#x4F7F;&#x7528;&#x7C7B;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Greeter {
    greeting: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(message: string) {
        <span class="hljs-keyword">this</span>.greeting = message;
    }
    greet() {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Hello, &quot;</span> + <span class="hljs-keyword">this</span>.greeting;
    }
}

<span class="hljs-keyword">let</span> greeter = <span class="hljs-keyword">new</span> Greeter(<span class="hljs-string">&quot;world&quot;</span>);
</code></pre>
<p>&#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528;&#x8FC7;C#&#x6216;Java&#xFF0C;&#x4F60;&#x4F1A;&#x5BF9;&#x8FD9;&#x79CD;&#x8BED;&#x6CD5;&#x975E;&#x5E38;&#x719F;&#x6089;&#x3002;
&#x6211;&#x4EEC;&#x58F0;&#x660E;&#x4E00;&#x4E2A;<code>Greeter</code>&#x7C7B;&#x3002;&#x8FD9;&#x4E2A;&#x7C7B;&#x6709;3&#x4E2A;&#x6210;&#x5458;&#xFF1A;&#x4E00;&#x4E2A;&#x53EB;&#x505A;<code>greeting</code>&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x548C;&#x4E00;&#x4E2A;<code>greet</code>&#x65B9;&#x6CD5;&#x3002;</p>
<p>&#x4F60;&#x4F1A;&#x6CE8;&#x610F;&#x5230;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x5F15;&#x7528;&#x4EFB;&#x4F55;&#x4E00;&#x4E2A;&#x7C7B;&#x6210;&#x5458;&#x7684;&#x65F6;&#x5019;&#x90FD;&#x7528;&#x4E86;<code>this</code>&#x3002;
&#x5B83;&#x8868;&#x793A;&#x6211;&#x4EEC;&#x8BBF;&#x95EE;&#x7684;&#x662F;&#x7C7B;&#x7684;&#x6210;&#x5458;&#x3002;</p>
<p>&#x6700;&#x540E;&#x4E00;&#x884C;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>new</code>&#x6784;&#x9020;&#x4E86;<code>Greeter</code>&#x7C7B;&#x7684;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x3002;
&#x5B83;&#x4F1A;&#x8C03;&#x7528;&#x4E4B;&#x524D;&#x5B9A;&#x4E49;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>Greeter</code>&#x7C7B;&#x578B;&#x7684;&#x65B0;&#x5BF9;&#x8C61;&#xFF0C;&#x5E76;&#x6267;&#x884C;&#x6784;&#x9020;&#x51FD;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5B83;&#x3002;</p>
<h1 id="&#x7EE7;&#x627F;">&#x7EE7;&#x627F;</h1>
<p>&#x5728;TypeScript&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5E38;&#x7528;&#x7684;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x6A21;&#x5F0F;&#x3002;
&#x57FA;&#x4E8E;&#x7C7B;&#x7684;&#x7A0B;&#x5E8F;&#x8BBE;&#x8BA1;&#x4E2D;&#x4E00;&#x79CD;&#x6700;&#x57FA;&#x672C;&#x7684;&#x6A21;&#x5F0F;&#x662F;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x7EE7;&#x627F;&#x6765;&#x6269;&#x5C55;&#x73B0;&#x6709;&#x7684;&#x7C7B;&#x3002;</p>
<p>&#x770B;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    move(distanceInMeters: <span class="hljs-built_in">number</span> = <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Animal moved <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
    }
}

<span class="hljs-keyword">class</span> Dog extends Animal {
    bark() {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Woof! Woof!&apos;</span>);
    }
}

<span class="hljs-keyword">const</span> dog = <span class="hljs-keyword">new</span> Dog();
dog.bark();
dog.move(<span class="hljs-number">10</span>);
dog.bark();
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x5C55;&#x793A;&#x4E86;&#x6700;&#x57FA;&#x672C;&#x7684;&#x7EE7;&#x627F;&#xFF1A;&#x7C7B;&#x4ECE;&#x57FA;&#x7C7B;&#x4E2D;&#x7EE7;&#x627F;&#x4E86;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#x3002;
&#x8FD9;&#x91CC;&#xFF0C;<code>Dog</code>&#x662F;&#x4E00;&#x4E2A;<em>&#x6D3E;&#x751F;&#x7C7B;</em>&#xFF0C;&#x5B83;&#x6D3E;&#x751F;&#x81EA;<code>Animal</code><em>&#x57FA;&#x7C7B;</em>&#xFF0C;&#x901A;&#x8FC7;<code>extends</code>&#x5173;&#x952E;&#x5B57;&#x3002;
&#x6D3E;&#x751F;&#x7C7B;&#x901A;&#x5E38;&#x88AB;&#x79F0;&#x4F5C;<em>&#x5B50;&#x7C7B;</em>&#xFF0C;&#x57FA;&#x7C7B;&#x901A;&#x5E38;&#x88AB;&#x79F0;&#x4F5C;<em>&#x8D85;&#x7C7B;</em>&#x3002;</p>
<p>&#x56E0;&#x4E3A;<code>Dog</code>&#x7EE7;&#x627F;&#x4E86;<code>Animal</code>&#x7684;&#x529F;&#x80FD;&#xFF0C;&#x56E0;&#x6B64;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>Dog</code>&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;&#x5B83;&#x80FD;&#x591F;<code>bark()</code>&#x548C;<code>move()</code>&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x4E2A;&#x66F4;&#x52A0;&#x590D;&#x6742;&#x7684;&#x4F8B;&#x5B50;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(theName: string) { <span class="hljs-keyword">this</span>.name = theName; }
    move(distanceInMeters: <span class="hljs-built_in">number</span> = <span class="hljs-number">0</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${this.name}</span> moved <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
    }
}

<span class="hljs-keyword">class</span> Snake extends Animal {
    <span class="hljs-keyword">constructor</span>(name: string) { <span class="hljs-keyword">super</span>(name); }
    move(distanceInMeters = <span class="hljs-number">5</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Slithering...&quot;</span>);
        <span class="hljs-keyword">super</span>.move(distanceInMeters);
    }
}

<span class="hljs-keyword">class</span> Horse extends Animal {
    <span class="hljs-keyword">constructor</span>(name: string) { <span class="hljs-keyword">super</span>(name); }
    move(distanceInMeters = <span class="hljs-number">45</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Galloping...&quot;</span>);
        <span class="hljs-keyword">super</span>.move(distanceInMeters);
    }
}

<span class="hljs-keyword">let</span> sam = <span class="hljs-keyword">new</span> Snake(<span class="hljs-string">&quot;Sammy the Python&quot;</span>);
<span class="hljs-keyword">let</span> tom: Animal = <span class="hljs-keyword">new</span> Horse(<span class="hljs-string">&quot;Tommy the Palomino&quot;</span>);

sam.move();
tom.move(<span class="hljs-number">34</span>);
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x5C55;&#x793A;&#x4E86;&#x4E00;&#x4E9B;&#x4E0A;&#x9762;&#x6CA1;&#x6709;&#x63D0;&#x5230;&#x7684;&#x7279;&#x6027;&#x3002;
&#x8FD9;&#x4E00;&#x6B21;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>extends</code>&#x5173;&#x952E;&#x5B57;&#x521B;&#x5EFA;&#x4E86;<code>Animal</code>&#x7684;&#x4E24;&#x4E2A;&#x5B50;&#x7C7B;&#xFF1A;<code>Horse</code>&#x548C;<code>Snake</code>&#x3002;</p>
<p>&#x4E0E;&#x524D;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x7684;&#x4E0D;&#x540C;&#x70B9;&#x662F;&#xFF0C;&#x6D3E;&#x751F;&#x7C7B;&#x5305;&#x542B;&#x4E86;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x5B83;<em>&#x5FC5;&#x987B;</em>&#x8C03;&#x7528;<code>super()</code>&#xFF0C;&#x5B83;&#x4F1A;&#x6267;&#x884C;&#x57FA;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;
&#x800C;&#x4E14;&#xFF0C;&#x5728;&#x6784;&#x9020;&#x51FD;&#x6570;&#x91CC;&#x8BBF;&#x95EE;<code>this</code>&#x7684;&#x5C5E;&#x6027;&#x4E4B;&#x524D;&#xFF0C;&#x6211;&#x4EEC;<em>&#x4E00;&#x5B9A;</em>&#x8981;&#x8C03;&#x7528;<code>super()</code>&#x3002;
&#x8FD9;&#x4E2A;&#x662F;TypeScript&#x5F3A;&#x5236;&#x6267;&#x884C;&#x7684;&#x4E00;&#x6761;&#x91CD;&#x8981;&#x89C4;&#x5219;&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x6F14;&#x793A;&#x4E86;&#x5982;&#x4F55;&#x5728;&#x5B50;&#x7C7B;&#x91CC;&#x53EF;&#x4EE5;&#x91CD;&#x5199;&#x7236;&#x7C7B;&#x7684;&#x65B9;&#x6CD5;&#x3002;
<code>Snake</code>&#x7C7B;&#x548C;<code>Horse</code>&#x7C7B;&#x90FD;&#x521B;&#x5EFA;&#x4E86;<code>move</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5B83;&#x4EEC;&#x91CD;&#x5199;&#x4E86;&#x4ECE;<code>Animal</code>&#x7EE7;&#x627F;&#x6765;&#x7684;<code>move</code>&#x65B9;&#x6CD5;&#xFF0C;&#x4F7F;&#x5F97;<code>move</code>&#x65B9;&#x6CD5;&#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x7C7B;&#x800C;&#x5177;&#x6709;&#x4E0D;&#x540C;&#x7684;&#x529F;&#x80FD;&#x3002;
&#x6CE8;&#x610F;&#xFF0C;&#x5373;&#x4F7F;<code>tom</code>&#x88AB;&#x58F0;&#x660E;&#x4E3A;<code>Animal</code>&#x7C7B;&#x578B;&#xFF0C;&#x4F46;&#x56E0;&#x4E3A;&#x5B83;&#x7684;&#x503C;&#x662F;<code>Horse</code>&#xFF0C;&#x8C03;&#x7528;<code>tom.move(34)</code>&#x65F6;&#xFF0C;&#x5B83;&#x4F1A;&#x8C03;&#x7528;<code>Horse</code>&#x91CC;&#x91CD;&#x5199;&#x7684;&#x65B9;&#x6CD5;&#xFF1A;</p>
<pre><code class="lang-text">Slithering...
Sammy the Python moved 5m.
Galloping...
Tommy the Palomino moved 34m.
</code></pre>
<h1 id="&#x516C;&#x5171;&#xFF0C;&#x79C1;&#x6709;&#x4E0E;&#x53D7;&#x4FDD;&#x62A4;&#x7684;&#x4FEE;&#x9970;&#x7B26;">&#x516C;&#x5171;&#xFF0C;&#x79C1;&#x6709;&#x4E0E;&#x53D7;&#x4FDD;&#x62A4;&#x7684;&#x4FEE;&#x9970;&#x7B26;</h1>
<h2 id="&#x9ED8;&#x8BA4;&#x4E3A;public">&#x9ED8;&#x8BA4;&#x4E3A;<code>public</code></h2>
<p>&#x5728;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x81EA;&#x7531;&#x7684;&#x8BBF;&#x95EE;&#x7A0B;&#x5E8F;&#x91CC;&#x5B9A;&#x4E49;&#x7684;&#x6210;&#x5458;&#x3002;
&#x5982;&#x679C;&#x4F60;&#x5BF9;&#x5176;&#x5B83;&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x7C7B;&#x6BD4;&#x8F83;&#x4E86;&#x89E3;&#xFF0C;&#x5C31;&#x4F1A;&#x6CE8;&#x610F;&#x5230;&#x6211;&#x4EEC;&#x5728;&#x4E4B;&#x524D;&#x7684;&#x4EE3;&#x7801;&#x91CC;&#x5E76;&#x6CA1;&#x6709;&#x4F7F;&#x7528;<code>public</code>&#x6765;&#x505A;&#x4FEE;&#x9970;&#xFF1B;&#x4F8B;&#x5982;&#xFF0C;C#&#x8981;&#x6C42;&#x5FC5;&#x987B;&#x660E;&#x786E;&#x5730;&#x4F7F;&#x7528;<code>public</code>&#x6307;&#x5B9A;&#x6210;&#x5458;&#x662F;&#x53EF;&#x89C1;&#x7684;&#x3002;
&#x5728;TypeScript&#x91CC;&#xFF0C;&#x6210;&#x5458;&#x90FD;&#x9ED8;&#x8BA4;&#x4E3A;<code>public</code>&#x3002;</p>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x660E;&#x786E;&#x7684;&#x5C06;&#x4E00;&#x4E2A;&#x6210;&#x5458;&#x6807;&#x8BB0;&#x6210;<code>public</code>&#x3002;
&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;&#x4E0B;&#x9762;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x91CD;&#x5199;&#x4E0A;&#x9762;&#x7684;<code>Animal</code>&#x7C7B;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    <span class="hljs-keyword">public</span> name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">constructor</span>(theName: string) { <span class="hljs-keyword">this</span>.name = theName; }
    <span class="hljs-keyword">public</span> move(distanceInMeters: <span class="hljs-built_in">number</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${this.name}</span> moved <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
    }
}
</code></pre>
<h2 id="&#x7406;&#x89E3;private">&#x7406;&#x89E3;<code>private</code></h2>
<p>&#x5F53;&#x6210;&#x5458;&#x88AB;&#x6807;&#x8BB0;&#x6210;<code>private</code>&#x65F6;&#xFF0C;&#x5B83;&#x5C31;&#x4E0D;&#x80FD;&#x5728;&#x58F0;&#x660E;&#x5B83;&#x7684;&#x7C7B;&#x7684;&#x5916;&#x90E8;&#x8BBF;&#x95EE;&#x3002;&#x6BD4;&#x5982;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    <span class="hljs-keyword">private</span> name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(theName: string) { <span class="hljs-keyword">this</span>.name = theName; }
}

<span class="hljs-keyword">new</span> Animal(<span class="hljs-string">&quot;Cat&quot;</span>).name; <span class="hljs-comment">// &#x9519;&#x8BEF;: &apos;name&apos; &#x662F;&#x79C1;&#x6709;&#x7684;.</span>
</code></pre>
<p>TypeScript&#x4F7F;&#x7528;&#x7684;&#x662F;&#x7ED3;&#x6784;&#x6027;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;&#x3002;
&#x5F53;&#x6211;&#x4EEC;&#x6BD4;&#x8F83;&#x4E24;&#x79CD;&#x4E0D;&#x540C;&#x7684;&#x7C7B;&#x578B;&#x65F6;&#xFF0C;&#x5E76;&#x4E0D;&#x5728;&#x4E4E;&#x5B83;&#x4EEC;&#x4ECE;&#x4F55;&#x5904;&#x800C;&#x6765;&#xFF0C;&#x5982;&#x679C;&#x6240;&#x6709;&#x6210;&#x5458;&#x7684;&#x7C7B;&#x578B;&#x90FD;&#x662F;&#x517C;&#x5BB9;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x8BA4;&#x4E3A;&#x5B83;&#x4EEC;&#x7684;&#x7C7B;&#x578B;&#x662F;&#x517C;&#x5BB9;&#x7684;&#x3002;</p>
<p>&#x7136;&#x800C;&#xFF0C;&#x5F53;&#x6211;&#x4EEC;&#x6BD4;&#x8F83;&#x5E26;&#x6709;<code>private</code>&#x6216;<code>protected</code>&#x6210;&#x5458;&#x7684;&#x7C7B;&#x578B;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x60C5;&#x51B5;&#x5C31;&#x4E0D;&#x540C;&#x4E86;&#x3002;
&#x5982;&#x679C;&#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x91CC;&#x5305;&#x542B;&#x4E00;&#x4E2A;<code>private</code>&#x6210;&#x5458;&#xFF0C;&#x90A3;&#x4E48;&#x53EA;&#x6709;&#x5F53;&#x53E6;&#x5916;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x4E2D;&#x4E5F;&#x5B58;&#x5728;&#x8FD9;&#x6837;&#x4E00;&#x4E2A;<code>private</code>&#x6210;&#x5458;&#xFF0C; &#x5E76;&#x4E14;&#x5B83;&#x4EEC;&#x90FD;&#x662F;&#x6765;&#x81EA;&#x540C;&#x4E00;&#x5904;&#x58F0;&#x660E;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x624D;&#x8BA4;&#x4E3A;&#x8FD9;&#x4E24;&#x4E2A;&#x7C7B;&#x578B;&#x662F;&#x517C;&#x5BB9;&#x7684;&#x3002;
&#x5BF9;&#x4E8E;<code>protected</code>&#x6210;&#x5458;&#x4E5F;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x89C4;&#x5219;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x6765;&#x770B;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x66F4;&#x597D;&#x5730;&#x8BF4;&#x660E;&#x4E86;&#x8FD9;&#x4E00;&#x70B9;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    <span class="hljs-keyword">private</span> name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(theName: string) { <span class="hljs-keyword">this</span>.name = theName; }
}

<span class="hljs-keyword">class</span> Rhino extends Animal {
    <span class="hljs-keyword">constructor</span>() { <span class="hljs-keyword">super</span>(<span class="hljs-string">&quot;Rhino&quot;</span>); }
}

<span class="hljs-keyword">class</span> Employee {
    <span class="hljs-keyword">private</span> name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(theName: string) { <span class="hljs-keyword">this</span>.name = theName; }
}

<span class="hljs-keyword">let</span> animal = <span class="hljs-keyword">new</span> Animal(<span class="hljs-string">&quot;Goat&quot;</span>);
<span class="hljs-keyword">let</span> rhino = <span class="hljs-keyword">new</span> Rhino();
<span class="hljs-keyword">let</span> employee = <span class="hljs-keyword">new</span> Employee(<span class="hljs-string">&quot;Bob&quot;</span>);

animal = rhino;
animal = employee; <span class="hljs-comment">// &#x9519;&#x8BEF;: Animal &#x4E0E; Employee &#x4E0D;&#x517C;&#x5BB9;.</span>
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4E2D;&#x6709;<code>Animal</code>&#x548C;<code>Rhino</code>&#x4E24;&#x4E2A;&#x7C7B;&#xFF0C;<code>Rhino</code>&#x662F;<code>Animal</code>&#x7C7B;&#x7684;&#x5B50;&#x7C7B;&#x3002;
&#x8FD8;&#x6709;&#x4E00;&#x4E2A;<code>Employee</code>&#x7C7B;&#xFF0C;&#x5176;&#x7C7B;&#x578B;&#x770B;&#x4E0A;&#x53BB;&#x4E0E;<code>Animal</code>&#x662F;&#x76F8;&#x540C;&#x7684;&#x3002;
&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x4E86;&#x51E0;&#x4E2A;&#x8FD9;&#x4E9B;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#xFF0C;&#x5E76;&#x76F8;&#x4E92;&#x8D4B;&#x503C;&#x6765;&#x770B;&#x770B;&#x4F1A;&#x53D1;&#x751F;&#x4EC0;&#x4E48;&#x3002;
&#x56E0;&#x4E3A;<code>Animal</code>&#x548C;<code>Rhino</code>&#x5171;&#x4EAB;&#x4E86;&#x6765;&#x81EA;<code>Animal</code>&#x91CC;&#x7684;&#x79C1;&#x6709;&#x6210;&#x5458;&#x5B9A;&#x4E49;<code>private name: string</code>&#xFF0C;&#x56E0;&#x6B64;&#x5B83;&#x4EEC;&#x662F;&#x517C;&#x5BB9;&#x7684;&#x3002;
&#x7136;&#x800C;<code>Employee</code>&#x5374;&#x4E0D;&#x662F;&#x8FD9;&#x6837;&#x3002;&#x5F53;&#x628A;<code>Employee</code>&#x8D4B;&#x503C;&#x7ED9;<code>Animal</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x9519;&#x8BEF;&#xFF0C;&#x8BF4;&#x5B83;&#x4EEC;&#x7684;&#x7C7B;&#x578B;&#x4E0D;&#x517C;&#x5BB9;&#x3002;
&#x5C3D;&#x7BA1;<code>Employee</code>&#x91CC;&#x4E5F;&#x6709;&#x4E00;&#x4E2A;&#x79C1;&#x6709;&#x6210;&#x5458;<code>name</code>&#xFF0C;&#x4F46;&#x5B83;&#x660E;&#x663E;&#x4E0D;&#x662F;<code>Animal</code>&#x91CC;&#x9762;&#x5B9A;&#x4E49;&#x7684;&#x90A3;&#x4E2A;&#x3002;</p>
<h2 id="&#x7406;&#x89E3;protected">&#x7406;&#x89E3;<code>protected</code></h2>
<p><code>protected</code>&#x4FEE;&#x9970;&#x7B26;&#x4E0E;<code>private</code>&#x4FEE;&#x9970;&#x7B26;&#x7684;&#x884C;&#x4E3A;&#x5F88;&#x76F8;&#x4F3C;&#xFF0C;&#x4F46;&#x6709;&#x4E00;&#x70B9;&#x4E0D;&#x540C;&#xFF0C;<code>protected</code>&#x6210;&#x5458;&#x5728;&#x6D3E;&#x751F;&#x7C7B;&#x4E2D;&#x4ECD;&#x7136;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x3002;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Person {
    <span class="hljs-keyword">protected</span> name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(name: string) { <span class="hljs-keyword">this</span>.name = name; }
}

<span class="hljs-keyword">class</span> Employee extends Person {
    <span class="hljs-keyword">private</span> department: <span class="hljs-built_in">string</span>;

    <span class="hljs-keyword">constructor</span>(name: string, department: string) {
        <span class="hljs-keyword">super</span>(name)
        <span class="hljs-keyword">this</span>.department = department;
    }

    <span class="hljs-keyword">public</span> getElevatorPitch() {
        <span class="hljs-keyword">return</span> <span class="hljs-string">`Hello, my name is <span class="hljs-subst">${this.name}</span> and I work in <span class="hljs-subst">${this.department}</span>.`</span>;
    }
}

<span class="hljs-keyword">let</span> howard = <span class="hljs-keyword">new</span> Employee(<span class="hljs-string">&quot;Howard&quot;</span>, <span class="hljs-string">&quot;Sales&quot;</span>);
<span class="hljs-built_in">console</span>.log(howard.getElevatorPitch());
<span class="hljs-built_in">console</span>.log(howard.name); <span class="hljs-comment">// &#x9519;&#x8BEF;</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x80FD;&#x5728;<code>Person</code>&#x7C7B;&#x5916;&#x4F7F;&#x7528;<code>name</code>&#xFF0C;&#x4F46;&#x662F;&#x6211;&#x4EEC;&#x4ECD;&#x7136;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>Employee</code>&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x8BBF;&#x95EE;&#xFF0C;&#x56E0;&#x4E3A;<code>Employee</code>&#x662F;&#x7531;<code>Person</code>&#x6D3E;&#x751F;&#x800C;&#x6765;&#x7684;&#x3002;</p>
<p>&#x6784;&#x9020;&#x51FD;&#x6570;&#x4E5F;&#x53EF;&#x4EE5;&#x88AB;&#x6807;&#x8BB0;&#x6210;<code>protected</code>&#x3002;
&#x8FD9;&#x610F;&#x5473;&#x7740;&#x8FD9;&#x4E2A;&#x7C7B;&#x4E0D;&#x80FD;&#x5728;&#x5305;&#x542B;&#x5B83;&#x7684;&#x7C7B;&#x5916;&#x88AB;&#x5B9E;&#x4F8B;&#x5316;&#xFF0C;&#x4F46;&#x662F;&#x80FD;&#x88AB;&#x7EE7;&#x627F;&#x3002;&#x6BD4;&#x5982;&#xFF0C;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Person {
    <span class="hljs-keyword">protected</span> name: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">protected</span> <span class="hljs-keyword">constructor</span>(theName: string) { <span class="hljs-keyword">this</span>.name = theName; }
}

<span class="hljs-comment">// Employee &#x80FD;&#x591F;&#x7EE7;&#x627F; Person</span>
<span class="hljs-keyword">class</span> Employee extends Person {
    <span class="hljs-keyword">private</span> department: <span class="hljs-built_in">string</span>;

    <span class="hljs-keyword">constructor</span>(name: string, department: string) {
        <span class="hljs-keyword">super</span>(name);
        <span class="hljs-keyword">this</span>.department = department;
    }

    <span class="hljs-keyword">public</span> getElevatorPitch() {
        <span class="hljs-keyword">return</span> <span class="hljs-string">`Hello, my name is <span class="hljs-subst">${this.name}</span> and I work in <span class="hljs-subst">${this.department}</span>.`</span>;
    }
}

<span class="hljs-keyword">let</span> howard = <span class="hljs-keyword">new</span> Employee(<span class="hljs-string">&quot;Howard&quot;</span>, <span class="hljs-string">&quot;Sales&quot;</span>);
<span class="hljs-keyword">let</span> john = <span class="hljs-keyword">new</span> Person(<span class="hljs-string">&quot;John&quot;</span>); <span class="hljs-comment">// &#x9519;&#x8BEF;: &apos;Person&apos; &#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x662F;&#x88AB;&#x4FDD;&#x62A4;&#x7684;.</span>
</code></pre>
<h1 id="readonly&#x4FEE;&#x9970;&#x7B26;">readonly&#x4FEE;&#x9970;&#x7B26;</h1>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>readonly</code>&#x5173;&#x952E;&#x5B57;&#x5C06;&#x5C5E;&#x6027;&#x8BBE;&#x7F6E;&#x4E3A;&#x53EA;&#x8BFB;&#x7684;&#x3002;
&#x53EA;&#x8BFB;&#x5C5E;&#x6027;&#x5FC5;&#x987B;&#x5728;&#x58F0;&#x660E;&#x65F6;&#x6216;&#x6784;&#x9020;&#x51FD;&#x6570;&#x91CC;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Octopus {
    readonly name: <span class="hljs-built_in">string</span>;
    readonly numberOfLegs: <span class="hljs-built_in">number</span> = <span class="hljs-number">8</span>;
    <span class="hljs-keyword">constructor</span> (theName: string) {
        <span class="hljs-keyword">this</span>.name = theName;
    }
}
<span class="hljs-keyword">let</span> dad = <span class="hljs-keyword">new</span> Octopus(<span class="hljs-string">&quot;Man with the 8 strong legs&quot;</span>);
dad.name = <span class="hljs-string">&quot;Man with the 3-piece suit&quot;</span>; <span class="hljs-comment">// &#x9519;&#x8BEF;! name &#x662F;&#x53EA;&#x8BFB;&#x7684;.</span>
</code></pre>
<h2 id="&#x53C2;&#x6570;&#x5C5E;&#x6027;">&#x53C2;&#x6570;&#x5C5E;&#x6027;</h2>
<p>&#x5728;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x4E0D;&#x5F97;&#x4E0D;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x53D7;&#x4FDD;&#x62A4;&#x7684;&#x6210;&#x5458;<code>name</code>&#x548C;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x53C2;&#x6570;<code>theName</code>&#x5728;<code>Person</code>&#x7C7B;&#x91CC;&#xFF0C;&#x5E76;&#x4E14;&#x7ACB;&#x523B;&#x5C06;<code>theName</code>&#x7684;&#x503C;&#x8D4B;&#x7ED9;<code>name</code>&#x3002;
&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x7ECF;&#x5E38;&#x4F1A;&#x9047;&#x5230;&#x3002;<em>&#x53C2;&#x6570;&#x5C5E;&#x6027;</em>&#x53EF;&#x4EE5;&#x65B9;&#x4FBF;&#x5730;&#x8BA9;&#x6211;&#x4EEC;&#x5728;&#x4E00;&#x4E2A;&#x5730;&#x65B9;&#x5B9A;&#x4E49;&#x5E76;&#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E2A;&#x6210;&#x5458;&#x3002;
&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x662F;&#x5BF9;&#x4E4B;&#x524D;<code>Animal</code>&#x7C7B;&#x7684;&#x4FEE;&#x6539;&#x7248;&#xFF0C;&#x4F7F;&#x7528;&#x4E86;&#x53C2;&#x6570;&#x5C5E;&#x6027;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Animal {
    <span class="hljs-keyword">constructor</span>(private name: string) { }
    move(distanceInMeters: <span class="hljs-built_in">number</span>) {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${this.name}</span> moved <span class="hljs-subst">${distanceInMeters}</span>m.`</span>);
    }
}
</code></pre>
<p>&#x6CE8;&#x610F;&#x770B;&#x6211;&#x4EEC;&#x662F;&#x5982;&#x4F55;&#x820D;&#x5F03;&#x4E86;<code>theName</code>&#xFF0C;&#x4EC5;&#x5728;&#x6784;&#x9020;&#x51FD;&#x6570;&#x91CC;&#x4F7F;&#x7528;<code>private name: string</code>&#x53C2;&#x6570;&#x6765;&#x521B;&#x5EFA;&#x548C;&#x521D;&#x59CB;&#x5316;<code>name</code>&#x6210;&#x5458;&#x3002;
&#x6211;&#x4EEC;&#x628A;&#x58F0;&#x660E;&#x548C;&#x8D4B;&#x503C;&#x5408;&#x5E76;&#x81F3;&#x4E00;&#x5904;&#x3002;</p>
<p>&#x53C2;&#x6570;&#x5C5E;&#x6027;&#x901A;&#x8FC7;&#x7ED9;&#x6784;&#x9020;&#x51FD;&#x6570;&#x53C2;&#x6570;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x8BBF;&#x95EE;&#x9650;&#x5B9A;&#x7B26;&#x6765;&#x58F0;&#x660E;&#x3002;
&#x4F7F;&#x7528;<code>private</code>&#x9650;&#x5B9A;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x5C5E;&#x6027;&#x4F1A;&#x58F0;&#x660E;&#x5E76;&#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E2A;&#x79C1;&#x6709;&#x6210;&#x5458;&#xFF1B;&#x5BF9;&#x4E8E;<code>public</code>&#x548C;<code>protected</code>&#x6765;&#x8BF4;&#x4E5F;&#x662F;&#x4E00;&#x6837;&#x3002;</p>
<h1 id="&#x5B58;&#x53D6;&#x5668;">&#x5B58;&#x53D6;&#x5668;</h1>
<p>TypeScript&#x652F;&#x6301;&#x901A;&#x8FC7;getters/setters&#x6765;&#x622A;&#x53D6;&#x5BF9;&#x5BF9;&#x8C61;&#x6210;&#x5458;&#x7684;&#x8BBF;&#x95EE;&#x3002;
&#x5B83;&#x80FD;&#x5E2E;&#x52A9;&#x4F60;&#x6709;&#x6548;&#x7684;&#x63A7;&#x5236;&#x5BF9;&#x5BF9;&#x8C61;&#x6210;&#x5458;&#x7684;&#x8BBF;&#x95EE;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x6765;&#x770B;&#x5982;&#x4F55;&#x628A;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x7C7B;&#x6539;&#x5199;&#x6210;&#x4F7F;&#x7528;<code>get</code>&#x548C;<code>set</code>&#x3002;
&#x9996;&#x5148;&#xFF0C;&#x6211;&#x4EEC;&#x4ECE;&#x4E00;&#x4E2A;&#x6CA1;&#x6709;&#x4F7F;&#x7528;&#x5B58;&#x53D6;&#x5668;&#x7684;&#x4F8B;&#x5B50;&#x5F00;&#x59CB;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Employee {
    fullName: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">let</span> employee = <span class="hljs-keyword">new</span> Employee();
employee.fullName = <span class="hljs-string">&quot;Bob Smith&quot;</span>;
<span class="hljs-keyword">if</span> (employee.fullName) {
    <span class="hljs-built_in">console</span>.log(employee.fullName);
}
</code></pre>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x968F;&#x610F;&#x7684;&#x8BBE;&#x7F6E;<code>fullName</code>&#xFF0C;&#x8FD9;&#x662F;&#x975E;&#x5E38;&#x65B9;&#x4FBF;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x8FD9;&#x4E5F;&#x53EF;&#x80FD;&#x4F1A;&#x5E26;&#x6765;&#x9EBB;&#x70E6;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x8FD9;&#x4E2A;&#x7248;&#x672C;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x5148;&#x68C0;&#x67E5;&#x7528;&#x6237;&#x5BC6;&#x7801;&#x662F;&#x5426;&#x6B63;&#x786E;&#xFF0C;&#x7136;&#x540E;&#x518D;&#x5141;&#x8BB8;&#x5176;&#x4FEE;&#x6539;&#x5458;&#x5DE5;&#x4FE1;&#x606F;&#x3002;
&#x6211;&#x4EEC;&#x628A;&#x5BF9;<code>fullName</code>&#x7684;&#x76F4;&#x63A5;&#x8BBF;&#x95EE;&#x6539;&#x6210;&#x4E86;&#x53EF;&#x4EE5;&#x68C0;&#x67E5;&#x5BC6;&#x7801;&#x7684;<code>set</code>&#x65B9;&#x6CD5;&#x3002;
&#x6211;&#x4EEC;&#x4E5F;&#x52A0;&#x4E86;&#x4E00;&#x4E2A;<code>get</code>&#x65B9;&#x6CD5;&#xFF0C;&#x8BA9;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x4ECD;&#x7136;&#x53EF;&#x4EE5;&#x5DE5;&#x4F5C;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> passcode = <span class="hljs-string">&quot;secret passcode&quot;</span>;

<span class="hljs-keyword">class</span> Employee {
    <span class="hljs-keyword">private</span> _fullName: <span class="hljs-built_in">string</span>;

    <span class="hljs-keyword">get</span> fullName(): <span class="hljs-built_in">string</span> {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._fullName;
    }

    <span class="hljs-keyword">set</span> fullName(newName: <span class="hljs-built_in">string</span>) {
        <span class="hljs-keyword">if</span> (passcode &amp;&amp; passcode == <span class="hljs-string">&quot;secret passcode&quot;</span>) {
            <span class="hljs-keyword">this</span>._fullName = newName;
        }
        <span class="hljs-keyword">else</span> {
            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;Error: Unauthorized update of employee!&quot;</span>);
        }
    }
}

<span class="hljs-keyword">let</span> employee = <span class="hljs-keyword">new</span> Employee();
employee.fullName = <span class="hljs-string">&quot;Bob Smith&quot;</span>;
<span class="hljs-keyword">if</span> (employee.fullName) {
    alert(employee.fullName);
}
</code></pre>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;&#x4E00;&#x4E0B;&#x5BC6;&#x7801;&#xFF0C;&#x6765;&#x9A8C;&#x8BC1;&#x4E00;&#x4E0B;&#x5B58;&#x53D6;&#x5668;&#x662F;&#x5426;&#x662F;&#x5DE5;&#x4F5C;&#x7684;&#x3002;&#x5F53;&#x5BC6;&#x7801;&#x4E0D;&#x5BF9;&#x65F6;&#xFF0C;&#x4F1A;&#x63D0;&#x793A;&#x6211;&#x4EEC;&#x6CA1;&#x6709;&#x6743;&#x9650;&#x53BB;&#x4FEE;&#x6539;&#x5458;&#x5DE5;&#x3002;</p>
<p>&#x5BF9;&#x4E8E;&#x5B58;&#x53D6;&#x5668;&#x6709;&#x4E0B;&#x9762;&#x51E0;&#x70B9;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#xFF1A;</p>
<p>&#x9996;&#x5148;&#xFF0C;&#x5B58;&#x53D6;&#x5668;&#x8981;&#x6C42;&#x4F60;&#x5C06;&#x7F16;&#x8BD1;&#x5668;&#x8BBE;&#x7F6E;&#x4E3A;&#x8F93;&#x51FA;ECMAScript 5&#x6216;&#x66F4;&#x9AD8;&#x3002;
&#x4E0D;&#x652F;&#x6301;&#x964D;&#x7EA7;&#x5230;ECMAScript 3&#x3002;
&#x5176;&#x6B21;&#xFF0C;&#x53EA;&#x5E26;&#x6709;<code>get</code>&#x4E0D;&#x5E26;&#x6709;<code>set</code>&#x7684;&#x5B58;&#x53D6;&#x5668;&#x81EA;&#x52A8;&#x88AB;&#x63A8;&#x65AD;&#x4E3A;<code>readonly</code>&#x3002;
&#x8FD9;&#x5728;&#x4ECE;&#x4EE3;&#x7801;&#x751F;&#x6210;<code>.d.ts</code>&#x6587;&#x4EF6;&#x65F6;&#x662F;&#x6709;&#x5E2E;&#x52A9;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x5229;&#x7528;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x7528;&#x6237;&#x4F1A;&#x770B;&#x5230;&#x4E0D;&#x5141;&#x8BB8;&#x591F;&#x6539;&#x53D8;&#x5B83;&#x7684;&#x503C;&#x3002;</p>
<h1 id="&#x9759;&#x6001;&#x5C5E;&#x6027;">&#x9759;&#x6001;&#x5C5E;&#x6027;</h1>
<p>&#x5230;&#x76EE;&#x524D;&#x4E3A;&#x6B62;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x8BA8;&#x8BBA;&#x4E86;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x6210;&#x5458;&#xFF0C;&#x90A3;&#x4E9B;&#x4EC5;&#x5F53;&#x7C7B;&#x88AB;&#x5B9E;&#x4F8B;&#x5316;&#x7684;&#x65F6;&#x5019;&#x624D;&#x4F1A;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x7684;&#x5C5E;&#x6027;&#x3002;
&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x7C7B;&#x7684;&#x9759;&#x6001;&#x6210;&#x5458;&#xFF0C;&#x8FD9;&#x4E9B;&#x5C5E;&#x6027;&#x5B58;&#x5728;&#x4E8E;&#x7C7B;&#x672C;&#x8EAB;&#x4E0A;&#x9762;&#x800C;&#x4E0D;&#x662F;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x4E0A;&#x3002;
&#x5728;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>static</code>&#x5B9A;&#x4E49;<code>origin</code>&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x662F;&#x6240;&#x6709;&#x7F51;&#x683C;&#x90FD;&#x4F1A;&#x7528;&#x5230;&#x7684;&#x5C5E;&#x6027;&#x3002;
&#x6BCF;&#x4E2A;&#x5B9E;&#x4F8B;&#x60F3;&#x8981;&#x8BBF;&#x95EE;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x90FD;&#x8981;&#x5728;<code>origin</code>&#x524D;&#x9762;&#x52A0;&#x4E0A;&#x7C7B;&#x540D;&#x3002;
&#x5982;&#x540C;&#x5728;&#x5B9E;&#x4F8B;&#x5C5E;&#x6027;&#x4E0A;&#x4F7F;&#x7528;<code>this.</code>&#x524D;&#x7F00;&#x6765;&#x8BBF;&#x95EE;&#x5C5E;&#x6027;&#x4E00;&#x6837;&#xFF0C;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>Grid.</code>&#x6765;&#x8BBF;&#x95EE;&#x9759;&#x6001;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Grid {
    <span class="hljs-keyword">static</span> origin = {x: <span class="hljs-number">0</span>, y: <span class="hljs-number">0</span>};
    calculateDistanceFromOrigin(point: {x: <span class="hljs-built_in">number</span>; y: <span class="hljs-built_in">number</span>;}) {
        <span class="hljs-keyword">let</span> xDist = (point.x - Grid.origin.x);
        <span class="hljs-keyword">let</span> yDist = (point.y - Grid.origin.y);
        <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.sqrt(xDist * xDist + yDist * yDist) / <span class="hljs-keyword">this</span>.scale;
    }
    <span class="hljs-keyword">constructor</span> (public scale: number) { }
}

<span class="hljs-keyword">let</span> grid1 = <span class="hljs-keyword">new</span> Grid(<span class="hljs-number">1.0</span>);  <span class="hljs-comment">// 1x scale</span>
<span class="hljs-keyword">let</span> grid2 = <span class="hljs-keyword">new</span> Grid(<span class="hljs-number">5.0</span>);  <span class="hljs-comment">// 5x scale</span>

<span class="hljs-built_in">console</span>.log(grid1.calculateDistanceFromOrigin({x: <span class="hljs-number">10</span>, y: <span class="hljs-number">10</span>}));
<span class="hljs-built_in">console</span>.log(grid2.calculateDistanceFromOrigin({x: <span class="hljs-number">10</span>, y: <span class="hljs-number">10</span>}));
</code></pre>
<h1 id="&#x62BD;&#x8C61;&#x7C7B;">&#x62BD;&#x8C61;&#x7C7B;</h1>
<p>&#x62BD;&#x8C61;&#x7C7B;&#x505A;&#x4E3A;&#x5176;&#x5B83;&#x6D3E;&#x751F;&#x7C7B;&#x7684;&#x57FA;&#x7C7B;&#x4F7F;&#x7528;&#x3002;
&#x5B83;&#x4EEC;&#x4E00;&#x822C;&#x4E0D;&#x4F1A;&#x76F4;&#x63A5;&#x88AB;&#x5B9E;&#x4F8B;&#x5316;&#x3002;
&#x4E0D;&#x540C;&#x4E8E;&#x63A5;&#x53E3;&#xFF0C;&#x62BD;&#x8C61;&#x7C7B;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x6210;&#x5458;&#x7684;&#x5B9E;&#x73B0;&#x7EC6;&#x8282;&#x3002;
<code>abstract</code>&#x5173;&#x952E;&#x5B57;&#x662F;&#x7528;&#x4E8E;&#x5B9A;&#x4E49;&#x62BD;&#x8C61;&#x7C7B;&#x548C;&#x5728;&#x62BD;&#x8C61;&#x7C7B;&#x5185;&#x90E8;&#x5B9A;&#x4E49;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">abstract</span> <span class="hljs-keyword">class</span> Animal {
    <span class="hljs-keyword">abstract</span> makeSound(): <span class="hljs-built_in">void</span>;
    move(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;roaming the earch...&apos;</span>);
    }
}
</code></pre>
<p>&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x7684;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x4E0D;&#x5305;&#x542B;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x5E76;&#x4E14;&#x5FC5;&#x987B;&#x5728;&#x6D3E;&#x751F;&#x7C7B;&#x4E2D;&#x5B9E;&#x73B0;&#x3002;
&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x7684;&#x8BED;&#x6CD5;&#x4E0E;&#x63A5;&#x53E3;&#x65B9;&#x6CD5;&#x76F8;&#x4F3C;&#x3002;
&#x4E24;&#x8005;&#x90FD;&#x662F;&#x5B9A;&#x4E49;&#x65B9;&#x6CD5;&#x7B7E;&#x540D;&#x4F46;&#x4E0D;&#x5305;&#x542B;&#x65B9;&#x6CD5;&#x4F53;&#x3002;
&#x7136;&#x800C;&#xFF0C;&#x62BD;&#x8C61;&#x65B9;&#x6CD5;&#x5FC5;&#x987B;&#x5305;&#x542B;<code>abstract</code>&#x5173;&#x952E;&#x5B57;&#x5E76;&#x4E14;&#x53EF;&#x4EE5;&#x5305;&#x542B;&#x8BBF;&#x95EE;&#x4FEE;&#x9970;&#x7B26;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">abstract</span> <span class="hljs-keyword">class</span> Department {

    <span class="hljs-keyword">constructor</span>(public name: string) {
    }

    printName(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Department name: &apos;</span> + <span class="hljs-keyword">this</span>.name);
    }

    <span class="hljs-keyword">abstract</span> printMeeting(): <span class="hljs-built_in">void</span>; <span class="hljs-comment">// &#x5FC5;&#x987B;&#x5728;&#x6D3E;&#x751F;&#x7C7B;&#x4E2D;&#x5B9E;&#x73B0;</span>
}

<span class="hljs-keyword">class</span> AccountingDepartment extends Department {

    <span class="hljs-keyword">constructor</span>() {
        <span class="hljs-keyword">super</span>(<span class="hljs-string">&apos;Accounting and Auditing&apos;</span>); <span class="hljs-comment">// &#x5728;&#x6D3E;&#x751F;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#x4E2D;&#x5FC5;&#x987B;&#x8C03;&#x7528; super()</span>
    }

    printMeeting(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;The Accounting Department meets each Monday at 10am.&apos;</span>);
    }

    generateReports(): <span class="hljs-built_in">void</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&apos;Generating accounting reports...&apos;</span>);
    }
}

<span class="hljs-keyword">let</span> department: Department; <span class="hljs-comment">// &#x5141;&#x8BB8;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5BF9;&#x62BD;&#x8C61;&#x7C7B;&#x578B;&#x7684;&#x5F15;&#x7528;</span>
department = <span class="hljs-keyword">new</span> Department(); <span class="hljs-comment">// &#x9519;&#x8BEF;: &#x4E0D;&#x80FD;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;</span>
department = <span class="hljs-keyword">new</span> AccountingDepartment(); <span class="hljs-comment">// &#x5141;&#x8BB8;&#x5BF9;&#x4E00;&#x4E2A;&#x62BD;&#x8C61;&#x5B50;&#x7C7B;&#x8FDB;&#x884C;&#x5B9E;&#x4F8B;&#x5316;&#x548C;&#x8D4B;&#x503C;</span>
department.printName();
department.printMeeting();
department.generateReports(); <span class="hljs-comment">// &#x9519;&#x8BEF;: &#x65B9;&#x6CD5;&#x5728;&#x58F0;&#x660E;&#x7684;&#x62BD;&#x8C61;&#x7C7B;&#x4E2D;&#x4E0D;&#x5B58;&#x5728;</span>
</code></pre>
<h1 id="&#x9AD8;&#x7EA7;&#x6280;&#x5DE7;">&#x9AD8;&#x7EA7;&#x6280;&#x5DE7;</h1>
<h2 id="&#x6784;&#x9020;&#x51FD;&#x6570;">&#x6784;&#x9020;&#x51FD;&#x6570;</h2>
<p>&#x5F53;&#x4F60;&#x5728;TypeScript&#x91CC;&#x58F0;&#x660E;&#x4E86;&#x4E00;&#x4E2A;&#x7C7B;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x540C;&#x65F6;&#x58F0;&#x660E;&#x4E86;&#x5F88;&#x591A;&#x4E1C;&#x897F;&#x3002;
&#x9996;&#x5148;&#x5C31;&#x662F;&#x7C7B;&#x7684;<em>&#x5B9E;&#x4F8B;</em>&#x7684;&#x7C7B;&#x578B;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Greeter {
    greeting: <span class="hljs-built_in">string</span>;
    <span class="hljs-keyword">constructor</span>(message: string) {
        <span class="hljs-keyword">this</span>.greeting = message;
    }
    greet() {
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Hello, &quot;</span> + <span class="hljs-keyword">this</span>.greeting;
    }
}

<span class="hljs-keyword">let</span> greeter: Greeter;
greeter = <span class="hljs-keyword">new</span> Greeter(<span class="hljs-string">&quot;world&quot;</span>);
<span class="hljs-built_in">console</span>.log(greeter.greet());
</code></pre>
<p>&#x8FD9;&#x91CC;&#xFF0C;&#x6211;&#x4EEC;&#x5199;&#x4E86;<code>let greeter: Greeter</code>&#xFF0C;&#x610F;&#x601D;&#x662F;<code>Greeter</code>&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x7684;&#x7C7B;&#x578B;&#x662F;<code>Greeter</code>&#x3002;
&#x8FD9;&#x5BF9;&#x4E8E;&#x7528;&#x8FC7;&#x5176;&#x5B83;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x8BED;&#x8A00;&#x7684;&#x7A0B;&#x5E8F;&#x5458;&#x6765;&#x8BB2;&#x5DF2;&#x7ECF;&#x662F;&#x8001;&#x4E60;&#x60EF;&#x4E86;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x53EB;&#x505A;<em>&#x6784;&#x9020;&#x51FD;&#x6570;</em>&#x7684;&#x503C;&#x3002;
&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x4F1A;&#x5728;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>new</code>&#x521B;&#x5EFA;&#x7C7B;&#x5B9E;&#x4F8B;&#x7684;&#x65F6;&#x5019;&#x88AB;&#x8C03;&#x7528;&#x3002;
&#x4E0B;&#x9762;&#x6211;&#x4EEC;&#x6765;&#x770B;&#x770B;&#xFF0C;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x88AB;&#x7F16;&#x8BD1;&#x6210;JavaScript&#x540E;&#x662F;&#x4EC0;&#x4E48;&#x6837;&#x5B50;&#x7684;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">let</span> Greeter = (<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Greeter</span>(<span class="hljs-params">message</span>) </span>{
        <span class="hljs-keyword">this</span>.greeting = message;
    }
    Greeter.prototype.greet = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Hello, &quot;</span> + <span class="hljs-keyword">this</span>.greeting;
    };
    <span class="hljs-keyword">return</span> Greeter;
})();

<span class="hljs-keyword">let</span> greeter;
greeter = <span class="hljs-keyword">new</span> Greeter(<span class="hljs-string">&quot;world&quot;</span>);
<span class="hljs-built_in">console</span>.log(greeter.greet());
</code></pre>
<p>&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x91CC;&#xFF0C;<code>let Greeter</code>&#x5C06;&#x88AB;&#x8D4B;&#x503C;&#x4E3A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;
&#x5F53;&#x6211;&#x4EEC;&#x8C03;&#x7528;<code>new</code>&#x5E76;&#x6267;&#x884C;&#x4E86;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x540E;&#xFF0C;&#x4FBF;&#x4F1A;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x3002;
&#x8FD9;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x4E5F;&#x5305;&#x542B;&#x4E86;&#x7C7B;&#x7684;&#x6240;&#x6709;&#x9759;&#x6001;&#x5C5E;&#x6027;&#x3002;
&#x6362;&#x4E2A;&#x89D2;&#x5EA6;&#x8BF4;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;&#x7C7B;&#x5177;&#x6709;<em>&#x5B9E;&#x4F8B;&#x90E8;&#x5206;</em>&#x4E0E;<em>&#x9759;&#x6001;&#x90E8;&#x5206;</em>&#x8FD9;&#x4E24;&#x4E2A;&#x90E8;&#x5206;&#x3002;</p>
<p>&#x8BA9;&#x6211;&#x4EEC;&#x7A0D;&#x5FAE;&#x6539;&#x5199;&#x4E00;&#x4E0B;&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x770B;&#x770B;&#x5B83;&#x4EEC;&#x4E4B;&#x95F4;&#x7684;&#x533A;&#x522B;&#xFF1A;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Greeter {
    <span class="hljs-keyword">static</span> standardGreeting = <span class="hljs-string">&quot;Hello, there&quot;</span>;
    greeting: <span class="hljs-built_in">string</span>;
    greet() {
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">this</span>.greeting) {
            <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Hello, &quot;</span> + <span class="hljs-keyword">this</span>.greeting;
        }
        <span class="hljs-keyword">else</span> {
            <span class="hljs-keyword">return</span> Greeter.standardGreeting;
        }
    }
}

<span class="hljs-keyword">let</span> greeter1: Greeter;
greeter1 = <span class="hljs-keyword">new</span> Greeter();
<span class="hljs-built_in">console</span>.log(greeter1.greet());

<span class="hljs-keyword">let</span> greeterMaker: <span class="hljs-keyword">typeof</span> Greeter = Greeter;
greeterMaker.standardGreeting = <span class="hljs-string">&quot;Hey there!&quot;</span>;

<span class="hljs-keyword">let</span> greeter2: Greeter = <span class="hljs-keyword">new</span> greeterMaker();
<span class="hljs-built_in">console</span>.log(greeter2.greet());
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x91CC;&#xFF0C;<code>greeter1</code>&#x4E0E;&#x4E4B;&#x524D;&#x770B;&#x5230;&#x7684;&#x4E00;&#x6837;&#x3002;
&#x6211;&#x4EEC;&#x5B9E;&#x4F8B;&#x5316;<code>Greeter</code>&#x7C7B;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x3002;
&#x4E0E;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x770B;&#x5230;&#x7684;&#x4E00;&#x6837;&#x3002;</p>
<p>&#x518D;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#x7C7B;&#x3002;
&#x6211;&#x4EEC;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x53EB;&#x505A;<code>greeterMaker</code>&#x7684;&#x53D8;&#x91CF;&#x3002;
&#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x4FDD;&#x5B58;&#x4E86;&#x8FD9;&#x4E2A;&#x7C7B;&#x6216;&#x8005;&#x8BF4;&#x4FDD;&#x5B58;&#x4E86;&#x7C7B;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;
&#x7136;&#x540E;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>typeof Greeter</code>&#xFF0C;&#x610F;&#x601D;&#x662F;&#x53D6;Greeter&#x7C7B;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x5B9E;&#x4F8B;&#x7684;&#x7C7B;&#x578B;&#x3002;
&#x6216;&#x8005;&#x66F4;&#x786E;&#x5207;&#x7684;&#x8BF4;&#xFF0C;&quot;&#x544A;&#x8BC9;&#x6211;<code>Greeter</code>&#x6807;&#x8BC6;&#x7B26;&#x7684;&#x7C7B;&#x578B;&quot;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x6784;&#x9020;&#x51FD;&#x6570;&#x7684;&#x7C7B;&#x578B;&#x3002;
&#x8FD9;&#x4E2A;&#x7C7B;&#x578B;&#x5305;&#x542B;&#x4E86;&#x7C7B;&#x7684;&#x6240;&#x6709;&#x9759;&#x6001;&#x6210;&#x5458;&#x548C;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;
&#x4E4B;&#x540E;&#xFF0C;&#x5C31;&#x548C;&#x524D;&#x9762;&#x4E00;&#x6837;&#xFF0C;&#x6211;&#x4EEC;&#x5728;<code>greeterMaker</code>&#x4E0A;&#x4F7F;&#x7528;<code>new</code>&#xFF0C;&#x521B;&#x5EFA;<code>Greeter</code>&#x7684;&#x5B9E;&#x4F8B;&#x3002;</p>
<h2 id="&#x628A;&#x7C7B;&#x5F53;&#x505A;&#x63A5;&#x53E3;&#x4F7F;&#x7528;">&#x628A;&#x7C7B;&#x5F53;&#x505A;&#x63A5;&#x53E3;&#x4F7F;&#x7528;</h2>
<p>&#x5982;&#x4E0A;&#x4E00;&#x8282;&#x91CC;&#x6240;&#x8BB2;&#x7684;&#xFF0C;&#x7C7B;&#x5B9A;&#x4E49;&#x4F1A;&#x521B;&#x5EFA;&#x4E24;&#x4E2A;&#x4E1C;&#x897F;&#xFF1A;&#x7C7B;&#x7684;&#x5B9E;&#x4F8B;&#x7C7B;&#x578B;&#x548C;&#x4E00;&#x4E2A;&#x6784;&#x9020;&#x51FD;&#x6570;&#x3002;
&#x56E0;&#x4E3A;&#x7C7B;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x51FA;&#x7C7B;&#x578B;&#xFF0C;&#x6240;&#x4EE5;&#x4F60;&#x80FD;&#x591F;&#x5728;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x63A5;&#x53E3;&#x7684;&#x5730;&#x65B9;&#x4F7F;&#x7528;&#x7C7B;&#x3002;</p>
<pre><code class="lang-ts"><span class="hljs-keyword">class</span> Point {
    x: <span class="hljs-built_in">number</span>;
    y: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">interface</span> Point3d <span class="hljs-keyword">extends</span> Point {
    z: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">let</span> point3d: Point3d = {x: <span class="hljs-number">1</span>, y: <span class="hljs-number">2</span>, z: <span class="hljs-number">3</span>};
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Interfaces.html" class="navigation navigation-prev " aria-label="Previous page: 接口">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Functions.html" class="navigation navigation-next " aria-label="Next page: 函数">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"类","level":"1.3.4","depth":2,"next":{"title":"函数","level":"1.3.5","depth":2,"path":"doc/handbook/Functions.md","ref":"./doc/handbook/Functions.md","articles":[]},"previous":{"title":"接口","level":"1.3.3","depth":2,"path":"doc/handbook/Interfaces.md","ref":"./doc/handbook/Interfaces.md","articles":[]},"dir":"ltr"},"config":{"plugins":[],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Patrick Zhong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"preface.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"TypeScript Handbook","language":"zh-hans","gitbook":">3.0.0","description":"Translation of official TypeScript Handbook"},"file":{"path":"doc/handbook/Classes.md","mtime":"2018-10-13T09:48:54.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-13T09:57:42.904Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

